import service from '@/api/service'
import * as Constant from '@/utils/constant'
export default {
  namespaced: true,
    state: {
      user: {
        userName: null
      },
        perms: [],  // 用户权限标识集合
    },
    getters: {
   
    },
    mutations: {
        setPerms(state, perms){  // 用户权限标识集合
            state.perms = perms;
        },
        serUser (state, user) {
          state.user.userName = user.userName
        }
    },
    actions: {
      getWritePermission ({ state, commit, dispatch }, data) {
        let perms = []
        service.getWritePermission(data, response => {
          if (response.status === Constant.RESP_STATE_SUCCESS) {
            perms = response.data.data
          } else {
            ALERT.error()
          }
          commit('setPerms', perms)
        })
      },
      serUser ({ commit }, user) {
        commit('serUser', user)
      }
    }
}